var reorderList = function (head) {
  if (!head) return;
  let cur = head, mid = findMiddle(head);
  let rev = reverseList(mid.next);
  while (rev) {
    let temp = cur.next;
    cur.next = rev;
    rev = rev.next;
    cur.next.next = temp;
    cur = temp;
  }
  mid.next = null;
  return head;
}

var findMiddle = function (head) {
  if (!head) return;
  let middle = head;
  while (head && head.next) {
    head = head.next.next;
    middle = middle.next;
  }
  return middle;
}

var reverseList = function (head) {
  if (!head) return;
  let pre = null;
  while (head) {
    let temp = head.next;
    head.next = pre;
    pre = head;
    head = temp;
  }
  return pre;
}